package ccnt.pvc.scudwaremobile.service;

import ccnt.pvc.scudwaremobile.utils.IDataService;
import android.content.ComponentName;
import android.content.ServiceConnection;
import android.os.IBinder;
import android.util.Log;

public class ScudwareServiceConnection implements ServiceConnection {

	private final static String TAG = ScudwareServiceConnection.class.getName();
	private int requestCount = 0;
	private boolean isBound = false;
	private IDataService iDataService = null;
	
	@Override
	public void onServiceConnected(ComponentName name, IBinder service) {
		Log.d(TAG, "Service Connected:" + name);
		isBound = true;
		iDataService = IDataService.Stub.asInterface(service);
	}

	@Override
	public void onServiceDisconnected(ComponentName name) {
		isBound = false;
		iDataService = null;
	}

	public boolean isBound() {
		return isBound;
	}

	public void setBound(boolean isBound) {
		this.isBound = isBound;
	}
	
	public boolean isCountZero() {
		return requestCount == 0 ? true : false;
	}
	
	public void addCount() {
		requestCount++;
	}
	
	public void minusCount() {
		requestCount--;
	}

	public IDataService getiDataService() {
		return iDataService;
	}

	public void setiDataService(IDataService iDataService) {
		this.iDataService = iDataService;
	}
	
}
